package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LhkRoomType;
import com.ruoyi.system.service.ILhkRoomTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房间类型管理Controller
 * 
 * @author ruoyi
 * @date 2025-05-28
 */
@RestController
@RequestMapping("/system/type")
public class LhkRoomTypeController extends BaseController
{
    @Autowired
    private ILhkRoomTypeService lhkRoomTypeService;

    /**
     * 查询房间类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room_type:list')")
    @GetMapping("/list")
    public TableDataInfo list(LhkRoomType lhkRoomType)
    {
        System.out.println(lhkRoomType);
        startPage();
        List<LhkRoomType> list = lhkRoomTypeService.selectLhkRoomTypeList(lhkRoomType);
        return getDataTable(list);
    }

    /**
     * 导出房间类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room_type:export')")
    @Log(title = "房间类型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LhkRoomType lhkRoomType)
    {
        List<LhkRoomType> list = lhkRoomTypeService.selectLhkRoomTypeList(lhkRoomType);
        ExcelUtil<LhkRoomType> util = new ExcelUtil<LhkRoomType>(LhkRoomType.class);
        util.exportExcel(response, list, "房间类型管理数据");
    }

    /**
     * 获取房间类型管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room_type:query')")
    @GetMapping(value = "/{roomTypeId}")
    public AjaxResult getInfo(@PathVariable("roomTypeId") Long roomTypeId)
    {
        return success(lhkRoomTypeService.selectLhkRoomTypeByRoomTypeId(roomTypeId));
    }

    /**
     * 新增房间类型管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room_type:add')")
    @Log(title = "房间类型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LhkRoomType lhkRoomType)
    {
        return toAjax(lhkRoomTypeService.insertLhkRoomType(lhkRoomType));
    }

    /**
     * 修改房间类型管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room_type:edit')")
    @Log(title = "房间类型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LhkRoomType lhkRoomType)
    {
        return toAjax(lhkRoomTypeService.updateLhkRoomType(lhkRoomType));
    }

    /**
     * 删除房间类型管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room_type:remove')")
    @Log(title = "房间类型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roomTypeIds}")
    public AjaxResult remove(@PathVariable Long[] roomTypeIds)
    {
        return toAjax(lhkRoomTypeService.deleteLhkRoomTypeByRoomTypeIds(roomTypeIds));
    }
}
